<template>
  <div class="menuList">
    <a-menu mode="pop" show-collapse-button @collapse="onCollapse">
      <template v-if="mRouter != null">
        <div v-for="(v, i) in mRouter" :key="i">
          <template v-if="v.meta.mapKey == 1">
            <deskMenuItem :data="v.children[0]" />
          </template>
          <template v-else-if="v.meta.mapKey == 2">
            <deskSubMenu :data="v" />
          </template>
        </div>
      </template>
    </a-menu>
  </div>
</template>

<script lang="ts">
import { toRefs } from 'vue';
import importConfig from './menuList';
import { IconApps } from '@arco-design/web-vue/es/icon';
import deskMenuItem from '@com/base/deskMenuItem/deskMenuItem.vue';
import deskSubMenu from '@com/base/deskSubMenu/deskSubMenu.vue';
export default {
  components: {
    IconApps,
    deskMenuItem,
    deskSubMenu,
  },
  setup(props, eimt) {
    const { base, onCollapse, init } = importConfig(props, eimt);
    init();
    return {
      ...toRefs(base),
      onCollapse,
      init,
    };
  },
};
</script>

<style scoped>
.menuList {
  width: 100%;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  background-color: var(--color-neutral-2);
}

.menuList .arco-menu {
  width: 200px;
  height: 100%;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}

.menuList .arco-menu :deep(.arco-menu-collapse-button) {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.menuList .arco-menu:not(.arco-menu-collapsed) :deep(.arco-menu-collapse-button) {
  right: 0;
  bottom: 8px;
  transform: translateX(50%);
}

.menuList .arco-menu:not(.arco-menu-collapsed)::before {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 48px;
  height: 48px;
  background-color: inherit;
  border-radius: 50%;
  box-shadow: -4px 0 2px var(--color-bg-2), 0 0 1px rgba(0, 0, 0, 0.3);
  transform: translateX(50%);
}

.menuList .arco-menu.arco-menu-collapsed {
  width: 48px;
  height: auto;
  padding-top: 24px;
  padding-bottom: 138px;
  border-radius: 22px;
}

.menuList .arco-menu.arco-menu-collapsed :deep(.arco-menu-collapse-button) {
  right: 8px;
  bottom: 8px;
}
</style>
